package com.restart.game.common.util.response;


import com.restart.game.common.bean.result.ResultBean;
import com.restart.game.common.bean.result.ResultEnum;

public class ResultUtil {

    public static ResultBean success(int code,String msg,Object data) {
        return new ResultBean(code,msg,data,false);
    }
    public static ResultBean success(ResultEnum resultEnum, Object data) {
        return success(resultEnum.getCode(),resultEnum.getMsg(),data);
    }
    public static ResultBean success(String msg,Object data) {
        return success(ResultEnum.SUCCESS.getCode(), msg, data);
    }
    public static ResultBean success(String msg) {
        return success( msg, null);
    }
    public static ResultBean success() {
        return success("成功");
    }

    /**
     * 错误
     */

    public static ResultBean error(int code,String msg,Object data) {
        return new ResultBean(code,msg,data,true);
    }
    public static ResultBean error(ResultEnum resultEnum, Object data) {
        return error(resultEnum.getCode(),resultEnum.getMsg(),data);
    }
    public static ResultBean error(String msg,Object data) {
        return error(ResultEnum.ERROR.getCode(), msg, data);
    }
    public static ResultBean error(String msg) {
        return error( msg, null);
    }
    public static ResultBean error() {
        return error("失败");
    }

    /**返回body*/
    public static ResultBean successBody(Object data) {
        return success(ResultEnum.SUCCESS, data);
    }
}
